<?php
namespace Home\Model;
use Think\Model;
class OredsModel extends Model {
    protected $tableName = "Address";

    protected $_validate = array(
        array('names','require','请输入收货人姓名(必填)'),
        array('phones','require','请输入电话(必填)'),
        array('address','require','请输入详细地址(必填)'),
        array('you','require','请输入邮政编码(必填)')
    );

    function order(){
        $input = $this->create();
        if (empty($input)) {
            return;
        }
        $id = session('id');
        $names =$_REQUEST['names'];
        $phones = $_REQUEST['phones'];
        $address = $_REQUEST['address'];
        $you = $_REQUEST['you'];

        $data['names'] = $names;
        $data['address'] =$address;
        $data['phones'] = $phones;
        $data['you'] = $you;
        $data['infors_id'] = $id;

        $is = M('Address')->add($data);
        if(empty($is)){
            $this->error="新增地址失败!!";
        }
        return $is;
    }
}